
var da = new Date()
res = da.getTime()  // 毫秒
console.log(res)
res = da.getHours() +'.'
res += da.getMinutes()+'.'
res += da.getSeconds()
console.log(res)

daysOfQianDao = [new Date(2016, 4 - 1, 28).getTime(),new Date(2016, 4 - 1, 29).getTime()]
thisDay = new Date(2016, 4 - 1, 30).getTime();
res = daysOfQianDao.indexOf(thisDay)
console.log(res)
console.log(thisDay)


// Test Date()
var today = new Date();
var thisDate = today.getDate();
var thisWeek = today.getDay();
console.log("thisDaytime:"+today)
console.log("thisDay:"+thisDate)
console.log("thisWeek:"+thisWeek)

var year = today.getFullYear();
var month = today.getMonth()
console.log("year:"+year)
console.log("month:"+month)

var theday = new Date(year,month-1,0);
var daycount = theday.getDate();
console.log(theday)
console.log("daycount:"+daycount)
//today.

// 本月的第一天
var firstDayOfThisMonth = new Date(year,month,1);
console.log("firstDayOfThisMonth :"+firstDayOfThisMonth)
console.log(firstDayOfThisMonth.getDay())
var totalDayOfThisMonth = new Date(year,month+1,0).getDate();
console.log("totalDayOfThisMonth:"+totalDayOfThisMonth)
//上一个月的最后一天
var lastDayOfLastMonth = new Date(year,month,0);
var lastDayOfLastMonth_week = lastDayOfLastMonth.getDay();
var lastDayOfLastMonth_date = lastDayOfLastMonth.getDate();
console.log("lastDayOfLastMonth :"+lastDayOfLastMonth)

function showRiLi2(){
    var from =  new Date(year,month,-lastDayOfLastMonth_week);
    console.log("from :"+from)
    var index = 0;
    for(var row = 0;row <6;row++){
        for(var col = 0; col < 7 ;col++){
            from = new Date(year,month,-lastDayOfLastMonth_week + index);
            console.log(from.getDate())
            index++;
        }
    }
}
//showRiLi2()

var second =  firstDayOfThisMonth;
second.setFullYear(2012)

console.log(firstDayOfThisMonth)
console.log(second)
delete second
console.log(firstDayOfThisMonth)
console.log(second)
second= null
console.log(firstDayOfThisMonth)
console.log(second)


Date.prototype.format = function(format){
var o = {
"M+" : this.getMonth()+1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
"S" : this.getMilliseconds() //millisecond
}

if(/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
}

for(var k in o) {
if(new RegExp("("+ k +")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
}
}
return format;
} 

var str = today.format("yyyy-MM-dd hh:mm:ss,S"); 
console.log(str)